package com.dai.designpattern.prototype.general;

/**
 * @author daijiyong
 */
public class Man implements IPrototype {

    private int age;
    private String name;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public Man clone() {
        //在这里边写复制本对象的逻辑
        //可以这样手动创建
        Man concretePrototype = new Man();
        concretePrototype.setAge(this.age);
        concretePrototype.setName(this.name);
        return concretePrototype;
        //也可以使用这种方式也行
//        return (ConcretePrototype) BeanUtils.copy(this);
    }

    @Override
    public String toString() {
        return "ConcretePrototype{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }
}
